<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html class="win-frame">
<head>
<title>${name_china}管理-编辑${name_china}</title>
<%@include file="/common/head.jsp" %>

</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>${name_china}管理</span>
            <span class="split"></span>
            <span>编辑${name_china}</span>
        </div>
    </div>
    <div class="page-title-border"></div>
</div>

<form id="form" method="post">
    <div class="form-wrapper">
	  <div class="h4 distance-double">
        <span class="h4-title"><i class="icon icon-setting"></i>基本信息</span>
        <span class="h4-border"></span>
      </div>
      
      	 <input type="hidden" id="id" name="id"/> 
      	 <input type="hidden" id="pid" name="pid"/> 
      	 <input type="hidden" id="type" name="type" value="${type}"/> 
      
	     <div class="form-cont">
	        <p class="form-cont-title">排序号</p>
	        <input type="text" id="reorder" name="reorder" class="summer-input summer-validatebox"  data-validatebox="validType:['noNegativeNumber']"/> 
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title">图片</p>
	        <input type="hidden" id="img" name="img"/>
	        <p style="color:red">建议高：188px；宽：188px</p> 
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>名称</p>
	        <input type="text" id="name" name="name" class="summer-input summer-validatebox"  data-validatebox="validType:['required','maxLength[50]']"/> 
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>所属平台</p>
	        <input type="text" id="typePt" name="type" class="summer-input summer-validatebox"  data-validatebox="validType:['required','maxLength[50]']"/> 
	     </div>
	      <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>是否显示</p>
	         <input type="text" class="summer-input" id="isEffective" name="isEffective"/>
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title">备注</p>
	        <textarea class="summer-textarea" id="note" name="note"></textarea>
	     </div>
     
     <div class="form-btn-wrapper" id="funcbar">
        <a class="btn btn-normal" id="backBtn">关闭</a>
    </div>
  </div>
</form>
<script>
    
  var   editData,
        permission = CommonUtil.getPermission('${name_english}');
    
    $(function () {
    	editData = ${editData};
    	
    	//初始化funcbar
     	$('#funcbar').prepend($.funcbar({
            type: 'button',
            data: permission,
            permit: ['${name_english}:edit']
        }));
    	
     	$('#isEffective').combobox({
     		async:false,
 	        defaultValue : editData.isEffective,
            valueField : 'code',
            textField : 'name',
            url : COMMON_URL.getCode + '?type=T_DM_T_MARKET_SHARE_IS_VISIBLE'
        });
     	
    	var jsonType = $("#type").val();
    	var json = jsonType.split(',');
    	
     	
    	//初始化所属平台下拉 多选
    	 $('#typePt').combobox({
           valueField : 'code',
           textField : 'name',
           defaultValue: json,
           multiple : true ,
           url : COMMON_URL.getCode + '?type=T_DM_GOODS_CATEGORY_TYPE'
       }); 
    	
    	
     	 $('#form').form({
        	onLoadSuccess:function(data){
               
           }
        }).form('loadDataEdit', {
            data: editData
        });
     	 
     	
    	
     	 
     	$("#img").filePlugin({
       	 	type:'image'
         });
    	//保存按钮
    	$('#funcbar').on('click', 'a[data-permit="${name_english}:edit"]', submit);
    	
    	//返回按钮
    	$('#backBtn, #goBack').on('click',backMain);
    });
    
    
    
    //表单提交
    function submit() {
         $("#form").form({
        	 buttons : ['#saveBtn'],
             ajax: {
                 url: CONST_URL.EDIT
             },
             onSubmitSuccess: function (data) {
            	 $.stip({
   	                type:'ok',//显示类型 有info、 ok、 danger
   	                text: '保存成功！',
   	                onBeforeHide: function () {
   	                	/* backMain(); */
   	                	var pid = document.getElementById('pid').value;
                        parent.refreshPage(pid);
   	                }
            	 });
              }
         }).form("submit");
    }
    
    //返回主页面
    function backMain() {
    	window.location.href = CONST_URL.INIT_MAIN;
    }
    
    //请求url
    var CONST_URL = {
    	INIT_MAIN: basePath + "${common_url}initGoodscategory",
       	EDIT: basePath + "${common_url}edit"
    };
    
</script>
</body>
</html>